home *** CD-ROM | disk | FTP | other *** search
- //-------------------------------------------------------------------//
- // Euclid's algorithm
- //
-
- // Syntax: euclid ( M , N )
-
- // Description:
-
- // Euclid's algorithm computes the greatest common divisor of two
- // integers (M, and N).
- //-------------------------------------------------------------------//
-
- euclid = function ( M , N )
- {
- local( M, N )
-
- r = 1;
- while(r)
- {
- r = mod(M,N);
- if(r == 0) { break; }
- M = N;
- N = r;
- }
- return N;
- };
-